<template>
  <div class="zw-xiang">
    <custNavbar title="课程详情" uname="link-o" paths="" />
    <img class="zw-img" :src="obj.image" alt="" />
    <div class="wrapper">
      <van-tabs v-model="active" class="tabs" sticky>
        <van-tab title="课程介绍">
          <div class="content">
            <div class="scroll-container">
              <div class="zw-shao">
                <span class="zw-span1">{{ obj.title }}</span
                ><br />
                <van-rate
                  class="zw-rate"
                  v-model="value"
                  readonly
                  size="15"
                  color="rgb(243, 249, 66)"
                />
                <span class="zw-value">{{ value }}.0</span>
                <span class="zw-num">{{ obj.num }}人学过</span><br />
                <span class="zw-price">  {{ obj.price ? "￥" + (obj.price * obj.discount).toFixed(2) : "免费" }}</span>
              </div>
              <div class="zw-teacher">
                <dl>
                  <dt><img class="zw-img1" :src="obj.timage" alt="" /></dt>
                  <dd>
                    <span class="zw-name">{{ obj.tname }}</span
                    ><br />
                    <span class="zw-fans">{{ obj.tfans }}</span>
                  </dd>
                  <span class="zw-icon"><van-icon name="arrow" /></span>
                </dl>
              </div>
              <div class="zw-introduce">
                <span class="zw-in">课程介绍</span>
                <img
                  class="zw-img2"
                  src="https://cdn7.axureshop.com/demo2024/1098347/images/%E8%AF%BE%E7%A8%8B%E8%AF%A6%E6%83%85/u5392.png"
                  alt=""
                />
                <Content></Content>
                <div></div>
              </div>
            </div>
          </div>
        </van-tab>
        <van-tab title="目录">
          <div class="content">
            <div class="scroll-container">
              <div class="zw-catalogue">
                <h5>目录</h5>
                <span>第一章 课程导学</span>
                <ul v-for="item in current" :key="item._id">
                  <svg
                    t="1711968399675"
                    class="icon"
                    viewBox="0 0 1024 1024"
                    version="1.1"
                    xmlns="http://www.w3.org/2000/svg"
                    p-id="4072"
                    width="16"
                    height="16"
                  >
                    <path
                      d="M512 512m-505.393548 0a505.393548 505.393548 0 1 0 1010.787096 0 505.393548 505.393548 0 1 0-1010.787096 0Z"
                      fill="#bfbfbf"
                      fill-opacity=".5"
                      p-id="4073"
                    ></path>
                    <path
                      d="M721.845677 519.38271L411.639742 674.485677a8.258065 8.258065 0 0 1-11.949419-7.382709V356.897032a8.258065 8.258065 0 0 1 11.949419-7.382709l310.205935 155.102967a8.258065 8.258065 0 0 1 0 14.76542z"
                      fill="#bfbfbf"
                      p-id="4074"
                    ></path>
                  </svg>
                  <li>{{ item.title }}</li>
                </ul>
              </div>
            </div>
          </div>
        </van-tab>
        <van-tab title="评价">
          <div class="content">
            <div class="scroll-container"></div>
          </div>
        </van-tab>
        <van-tab title="推荐">
          <div class="content">
            <div class="scroll-container"></div>
          </div>
        </van-tab>
      </van-tabs>
    </div>
    <div class="zw-shopping">
      <span v-if="obj.price">
        {{ obj.price ? "￥" + (obj.price * obj.discount).toFixed(2) : "免费" }}</span
      >
      <van-button v-if="obj.price" class="zw-btn" @click="router.push('/orderform')"
        >立即购买</van-button
      >
      <van-button v-else class="zw-btn1" @click="router.push('/video')"
        >立即学习</van-button
      >
    </div>
  </div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import Content from "./content.vue";
import custNavbar from "@/components/custNavbar/index.vue";
const router = useRouter();
const value = ref(5.0);
const teacher = ref([]);
const current = ref([]);
const active = ref(null);
const obj = ref(JSON.parse(localStorage.getItem("listObj")) || {});
</script>
<style scoped lang="scss">
.zw-xiang {
  position: relative;
  overflow: auto;
  height: 100vh;

  .zw-evaluate {
    background-color: white;

    h6 {
      margin: 5px 20px;
    }

    .zw-shu {
      margin-left: 20px;
      margin-top: 26px;
      font-size: 60px;
      width: 100px;
    }

    #u6128 {
      border-width: 0px;
      position: absolute;
      left: 200px;
      top: 70px;
      width: 150px;
      height: 6px;
    }

    .box_22 {
      font-family: "SourceHanSansSC-Normal", "思源黑体 Normal", "思源黑体";
      font-weight: 400;
      font-style: normal;
      font-size: 14px;
    }

    #u6128_div {
      border-width: 0px;
      position: absolute;
      left: 10px;
      top: -20px;
      width: 130px;
      height: 6px;
      background: inherit;
      background-color: rgba(255, 98, 98, 1);
      border: none;
      border-radius: 8px;
      -moz-box-shadow: none;
      -webkit-box-shadow: none;
      box-shadow: none;
    }

    .progress-bar {
      background-color: #f3f3f3;
      position: relative;
    }

    .progress {
      height: 20px;
      background-color: #4caf50;
      position: absolute;
      width: 0;
    }
  }

  .zw-img {
    background-color: rgb(102, 110, 232);
    width: 100%;
    height: 200px;
    overflow: hidden;
  }

  .zw-shao {
    background-color: white;
    height: 100px;
  }
}

.wrapper {
  height: 55vh;
  overflow: hidden;
  position: relative;
  background-color: #f9f4f4;
}

.tabs {
  height: 43px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

.scroll-container[data-v-897d812f] {
  height: 48.9vh;
  overflow-y: auto;
}

.van-tab {
  height: calc(100% - 40px);
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 15px;
  box-sizing: border-box;
}

.content {
  position: sticky;
  top: 0;
}

.scroll-container {
  height: 50vh;
  overflow-y: auto;
}

.zw-span1 {
  font-size: 18px;
  font-weight: bold;
  margin: 10px 20px;
}

.zw-rate {
  margin: 0px 20px;
}

.zw-value {
  font-size: 15px;
  margin: 0px 2px;
}

.zw-num {
  font-size: 15px;
  margin: 0px 15px;
  color: #ddd;
}

.zw-price {
  font-size: 18px;
  margin: 0px 20px;
  font-weight: bold;
}

.zw-img1 {
  margin: 0px 20px;
}

.zw-name {
  font-size: 15px;
}

.zw-fans {
  font-size: 15px;
  color: #ddd;
}

.zw-icon {
  margin-left: 160px;
  margin-top: 18px;
}

.zw-introduce {
  background-color: white;
}

.zw-in {
  font-size: 16px;
  font-weight: bold;
  margin: 10px 20px;
}

.zw-img2 {
  border-width: 0px;
  width: 335px;
  height: 168px;
  margin: 0px 20px;
  margin-top: 10px;
}

.zw-catalogue {
  background-color: white;

  h5 {
    margin: 0px 20px;
  }

  span {
    font-size: 16px;
    margin: 10px 20px;
    font-weight: bold;
  }

  ul {
    margin: 0px 20px;
  }

  ul li {
    font-size: 15px;
  }

  ul li,
  ul svg {
    display: inline-block;
    margin: 0px 5px;
  }

  ul svg {
    margin-top: 10px;
  }
}

.zw-shopping {
  bottom: 0;
  height: 40px;
  line-height: 40px;

  span {
    color: red;
    font-size: 22px;
    font-weight: bold;
    width: 60px;
    margin: 0px 20px;
  }

  .zw-btn {
    background-color: rgba(102, 110, 232, 1);
    color: white;
    height: 30px;
    width: 120px;
    border-radius: 25px;
    float: right;
    margin: 7px 20px;
  }

  .zw-btn1 {
    background-color: rgba(102, 110, 232, 1);
    color: white;
    height: 35px;
    width: 80%;
    border-radius: 25px;
    margin: 0px 30px;
  }
}

dl {
  display: flex;
  margin: 10px 0px;
  background-color: white;

  img {
    width: 60px;
    height: 60px;
  }
}
</style>
